<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
      String path = request.getContextPath();
      String basePath = request.getScheme() + "://" + request.getServerName() + ":"
          + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <script>
      var $ = function(strId){ 
        return document.getElementById(strId);
      };
      function Action() {
        this.form = document.forms['actionForm'];
        this.strKeyword = $('txtKeyword').value;
        this.doValidate = function(){
          $('lblMessage').innerHTML = '';
          var key = this.strKeyword;
          var sign = (key && key.replace(/ /gi, '') != '');
          if (!sign) {
            $('lblMessage').innerHTML = 'Please type keyword to search.';
          };
          return sign;
        };
      };
      Action.prototype.doGet = function() {
        if (!this.doValidate()) return;
        this.form.method = 'get';
        this.form.submit();
      };
      Action.prototype.doPost = function() {
        if (!this.doValidate()) return;
        this.form.method = 'post';
        this.form.submit();
      };
	</script>
  </head>

  <body>
    <br>
    <br>
    <strong>This is my JSP page.</strong>
    <br>
    <form name="actionForm" action="http://localhost:8080/demo.servlet/servlet/HttpClientTest">
    <input type="text" size="40" id="txtKeyword" name="txtKeyword"/>
    <label id="lblMessage" style="color:#FF0000;"></label>
    <br>
    <input type="button" value="Do Get" id="btnGet" onclick="(new Action()).doGet();" />
    &nbsp;
    <input type="button" value="Do Post" id="btnPost" onclick="(new Action()).doPost();" />
    </form>
    <br>
  </body>
</html>
